package demon3;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

public class Test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable =new MyCallable();
        //这里注意如果用Future作为类型要强转,这是因为Thread类实现了Runnable接
        //Future<Integer> future=new FutureTask<>(myCallable);
        //Thread thread=new Thread((Runnable) future);
        FutureTask<Integer> futureTask = new FutureTask<>(myCallable);
        Thread thread=new Thread(futureTask);
        thread.start();
        int get=futureTask.get();
        System.out.println(get);
    }
}
